<?php

class SearchController extends Zend_Controller_Action {
	
	public function init(){
		$init = new Model_Init($this);
	}
	
	public function createAction() {
		$this->_helper->layout ()->disableLayout ();
		$this->_helper->viewRenderer->setNoRender ( true );
		
		$model = new Model_Search ( 'users' );
		$model->createIndex ();
		
	}
	
	
	public function updateAction() {
		$this->_helper->layout ()->disableLayout ();
		$this->_helper->viewRenderer->setNoRender ( true );
		
		$model = new Model_Search ( 'users' );
		$model->updateIndex ();
	}
	
	public function resultAction() {
		$search_form = new Form_Search ();
		
		if ($this->getRequest ()->isPost ()) {
			if ($search_form->isValid ( $this->getRequest ()->getPost () )) {
				$model = new Model_Search ('users');
				$query = $this->_getParam ( 'q');
				$this->view->hits = $model->search ( $query );
			}
		}
		
		
//		$this->view->form_search = $search_form;
		
	}

}